package com.sbr.seb.wicket.panel.application;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.list.PropertyListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.spring.injection.annot.SpringBean;

import com.sbr.seb.entity.livraison.Application;
import com.sbr.seb.planning.dao.ApplicationDao;

public class ListApplicationsPanel extends Panel {

	private static final long serialVersionUID = 1L;
	@SpringBean
	private ApplicationDao applicationDao;
	
    public ListApplicationsPanel(String id) {
    	super(id);
//    	List<Application> applicationsList = new ArrayList<Application>();
//    	applicationsList.add(new Application(0,"Item", "1.6.14"));
//    	applicationsList.add(new Application(0,"Administre", "1.7.2"));
    	
    	add(new PropertyListView<Application>("applicationsList", applicationDao.findAll()) {

			private static final long serialVersionUID = 1L;

			@Override
			protected void populateItem(ListItem<Application> item) {
				Application application = item.getModelObject();
				item.add(new Label("name", application.getName()));
				item.add(new Label("description", application.getDescription()));
			}
    		
    	});
    	
//    	add(new BookmarkablePageLink("addApplicationLink", AddApplication.class));
//    	add(new EditApplicationPanel("editApplicationPanel"));
		
    }

	public void setApplicationDao(ApplicationDao applicationDao) {
		this.applicationDao = applicationDao;
	}
    
}
